/*
  ArduDriver Throttle Setting Sketch
  Coded by Ritchie Wilson
*/
#include <Servo.h>

#define THROTTLE	10
#define THR_MIN		-100
#define THR_MAX		100
long thr		= 0;
float thr_pwm;
Servo ESC;

void setup()
{
	Serial.begin(38400);
	ESC.attach(THROTTLE);
}

void loop()
{
 eTronix_ESC();
}

void eTronix_ESC()
{
  	Serial.println("30");
	delay(1000);
  	Serial.println("29");
	delay(1000);
  	Serial.println("28");
	delay(1000);
  	Serial.println("27");
	delay(1000);
  	Serial.println("26");
	delay(1000);
  	Serial.println("25");
	delay(1000);
  	Serial.println("24");
	delay(1000);
  	Serial.println("23");
	delay(1000);
  	Serial.println("22");
	delay(1000);
  	Serial.println("21");
	delay(1000);
  	Serial.println("20");
	delay(1000);
	Serial.println("19");
	delay(1000);
  	Serial.println("18");
	delay(1000);
  	Serial.println("17");
	delay(1000);
  	Serial.println("16");
	delay(1000);
  	Serial.println("15");
	delay(1000);
  	Serial.println("14");
	delay(1000);
  	Serial.println("13");
	delay(1000);
  	Serial.println("12");
	delay(1000);
  	Serial.println("11");
	delay(1000);
  	Serial.println("10");
	delay(1000);
	Serial.println("9");
	delay(1000);
  	Serial.println("8");
	delay(1000);
  	Serial.println("7");
	delay(1000);
  	Serial.println("6");
	delay(1000);
  	Serial.println("5");
	delay(1000);
  	Serial.println("4");
	delay(1000);
  	Serial.println("3");
	delay(1000);
  	Serial.println("2");
	delay(1000);
  	Serial.println("1");
	delay(1000);
  	Serial.println("0");
	ESC.writeMicroseconds(1500);	// Stop position
	Serial.println("Throttle in stop position press Setup key. You have 5 seconds.");
	Serial.println("Red LED: ON Green LED: ON");
	delay(5000);
	ESC.writeMicroseconds(2000);	// 100% forward position
	Serial.println("100% forward throttle position press Setup key. You have 5 seconds");
	Serial.println("Red LED: OFF Green LED: ON");
	delay(5000);
	ESC.writeMicroseconds(1000);	// 100% reverse position
	Serial.println("100% reverse throttle position press Setup key. You have 5 seconds");
	Serial.println("Red LED: ON Green LED: OFF");
	delay(5000);
	ESC.writeMicroseconds(1500);	// 100% reverse position
	Serial.println("Throttle in stop position press Setup key. You have 50 seconds to disconnect power");
	Serial.println("Red LED: OFF Green LED: ON");
	delay(50000);
}
